package com.dfec.water.dashboard.controller;

import com.dfec.common.utils.AjaxResult;
import com.dfec.water.service.YdbWarnDeviceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 大屏-预警
 * @author tangrg
 * @email 1446232546@qq.com
 * @date 2025-02-2025/2/26 11:23:37
 */
@Tag(name = "大屏-预警")
@RestController
@RequestMapping("dashboard/monitor")
public class WarnController {

    @Resource
    private YdbWarnDeviceService warnDeviceService;


    /**
     * 获取预警项目
     */
    @GetMapping("/getWarnProject")
    @Operation(summary = "获取预警项目")
    public AjaxResult getWarnProject() {
        return AjaxResult.ok().put(warnDeviceService.getWarnProject());
    }


    /**
     * 获取当前项目的报警设备
     */
    @GetMapping("/getProjectWarnDevice")
    @Operation(summary = "获取当前项目的报警设备")
    public AjaxResult getWarnProject(@RequestParam("projectId")Long projectId) {
        return AjaxResult.ok().put(warnDeviceService.getProjectWarnDevice(projectId));
    }

    /**
     * 获取报警数据
     */
    @GetMapping("/getWarnData")
    @Operation(summary = "获取报警数据")
    public AjaxResult getWarnData(@RequestParam("deviceId")Long deviceId) {
        return AjaxResult.ok().put(warnDeviceService.getWarnData(deviceId));
    }

    /**
     * 获取前十条数据
     */
    @GetMapping("/getTopTen")
    @Operation(summary = "获取前十条数据")
    public AjaxResult getTopTen() {
        return AjaxResult.ok().put(warnDeviceService.getTopTen());
    }

}
